home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11388 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: mail2news.demon.co.uk!dfdesign.demon.co.uk
  2. From: Dominic Feeley <dom@dfdesign.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Beginer C please help me
  5. Date: Sat, 23 Mar 96 19:06:36 GMT
  6. Organization: DF Designs
  7. Message-ID: <827607996snz@dfdesign.demon.co.uk>
  8. References: <DoLCFx.B7x.0.bloor@torfree.net> <4iqd15$ajd@loki.tor.hookup.net>
  9. Reply-To: dom@dfdesign.demon.co.uk
  10. X-NNTP-Posting-Host: dfdesign.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.30
  12. X-Mail2News-Path: dfdesign.demon.co.uk
  13.  
  14. In article <4iqd15$ajd@loki.tor.hookup.net>
  15.            Rajendra_Singh@msn.com "Rajendra Singh" writes:
  16. > bz786@torfree.net (Sherif Asif) wrote:
  17. >  >  float n;
  18. >  >  n = ( 9 / 5 ) ;
  19. >  >  printf( "n=   %1.3f\n", n ) ;
  20. >  >  I have complied and run the programme & I got the answer n=1.000
  21. >  >  but Iam supposed to get answer 1.8.
  22. > You are dividing an integer by an integer, hence the result is an
  23. > integer.  Change one or both of the operands to a float, i. e. change
  24. > 9 to 9. and/or 5 to 5., and you will get the desired result.
  25.  
  26. It makes life much easier to make this 9.0 or 5.0 as it's more
  27. obvious you are using floating point numbers.
  28.  
  29. Regards,
  30. Dominic.
  31.  
  32. -- 
  33. Dominic Feeley
  34.